package com.jinke.api.modules.app.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * 价格计算枚举
 * @author huang
 * @data 2024-05-16
 */
@Getter
public enum CostComputeEnums {
    SECTION(1, "区间"),
    IMMOBILIZATION(2, "固定");
    @EnumValue
    @JsonValue
    private final int value;
    private final String desc;
    CostComputeEnums(final int value, final String desc) {
        this.value = value;
        this.desc = desc;
    }
    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static CostComputeEnums defaultEnum(int value) {
        for (CostComputeEnums type : CostComputeEnums.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("No element matches " + value);
    }
}
